package com.beerbear.nacossecondservice.service;

import com.beerbear.nacossecondservice.client.FirstServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 * @Author: Beer Bear
 */
@Service
public class OneService {
    private RestTemplate restTemplate;

    @Autowired
    public void setRestTemplate(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    /**
     * create by: Beer Bear
     * description: 调用Sercvice1中的接口
     * create time: 2021/8/18 21:36
     */
    public HashMap callService1(){
        // nacos-first-service是Nacos中的服务的名字
        String url = "http://nacos-first-service/firstService/call";
        HashMap response = restTemplate.getForObject(url,HashMap.class);
        return response;
    }

    @Autowired
    private FirstServiceClient firstServiceClient;

    public HashMap callService1ByFeign() {
        return firstServiceClient.feignCall();
    }
}
